// 引入二次封装的axios
import request from '@/utils/request'
import type { trademark, trademarkResponseData } from './model/trademark'

// 枚举
enum API{
    TRADEMARK = '/admin/product/baseTrademark/',
    UPDATETRADEMARK = '/admin/product/baseTrademark/update',
    ADDTRADEMARK = '/admin/product/baseTrademark/save',
    DELETETRADEMARK = '/admin/product/baseTrademark/remove/'
}

// 获取品牌列表接口
export const reqTrademarkList = (page:number,limit:number)=>request.get<any,trademarkResponseData>(API.TRADEMARK + `${page}/${limit}`)

// 获取添加或修改品牌的接口
export const reqAddOrUpdateTrademark = (data:trademark)=>{
    // 通过id来判断到底是添加还是修改
    if(data.id){
        // 修改,将修改后的数据传个服务器
        return request.put<any,any>(API.UPDATETRADEMARK,data)
    }else{
        // 添加,将添加的数据传给服务器
        return request.post<any,any>(API.ADDTRADEMARK,data)
    }
}

// 删除接口
export const reqDeleteTrademark = (id:number|string)=>request.delete<any,any>(API.DELETETRADEMARK + id)